#include <REGX52.H>
#include "Delay.h"
#include "MatrixLED.h"
#include "Timer0.h"

unsigned char Offset=0;
unsigned char code Animation[]={//code，放在flash里，但是不能修改

0x00,0x00,0x19,0x3E,0x7C,0x56,0x01,0x00,
0x00,0x20,0x7F,0xF8,0xB4,0x02,0x01,0x00,
0x00,0x00,0x01,0x02,0x1C,0x3C,0x7B,0x58,

0x00,0x00,0x19,0x3E,0x7C,0x56,0x01,0x00,
0x00,0x20,0x7F,0xF8,0xB4,0x02,0x01,0x00,
0x00,0x00,0x01,0x02,0x1C,0x3C,0x7B,0x58,
	
0x3C,0x42,0xA9,0x85,0x85,0xA9,0x42,0x3C,
0x3C,0x42,0xA5,0x85,0x85,0xA5,0x42,0x3C,
0x3C,0x42,0xA5,0x89,0x89,0xA5,0x42,0x3C,
0x3C,0x42,0xA5,0x89,0x89,0xA5,0x42,0x3C,
0x3C,0x42,0xA5,0x85,0x85,0xA5,0x42,0x3C,	
};

void main()
{
	unsigned char i;
	MatrixLED_Init();
	Timer0_Init();
	
	while(1)
	{
		for(i=0;i<8;i++)
		{
			MatrixLED_ShowColumn(i,Animation[i+Offset]);
		}
		
		
	}
	
}


void Timer0_Routine() interrupt 1  //定时器0的中断函数
{
	static unsigned int T0Count;//static静态局部变量，只有本函数能引用
	//退出函数不丢失T0Count变量
	
	TL0 = 0x18;		//设置定时初值
	TH0 = 0xFC;		//设置定时初值
	T0Count++;
	if(T0Count>=150)
	{
		Offset+=8;
		if(Offset>40)
			Offset=0;
		//清零重记次
		T0Count=0;
	}
	
}
